/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author David
 */
@Entity
@Table(name = "produccio")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Produccio.findAll", query = "SELECT p FROM Produccio p"),
    @NamedQuery(name = "Produccio.findByDataPlanta", query = "SELECT p FROM Produccio p WHERE p.dataPlanta = :dataPlanta"),
    @NamedQuery(name = "Produccio.findByQuantitat", query = "SELECT p FROM Produccio p WHERE p.quantitat = :quantitat"),
    @NamedQuery(name = "Produccio.findByOrigen", query = "SELECT p FROM Produccio p WHERE p.origen = :origen"),
    @NamedQuery(name = "Produccio.findByVarietat", query = "SELECT p FROM Produccio p WHERE p.varietat = :varietat"),
    @NamedQuery(name = "Produccio.findByTerminado", query = "SELECT p FROM Produccio p WHERE p.terminado = :terminado"),
    @NamedQuery(name = "Produccio.findById", query = "SELECT p FROM Produccio p WHERE p.id = :id"),
    @NamedQuery(name = "Produccio.findByPosx1", query = "SELECT p FROM Produccio p WHERE p.posx1 = :posx1"),
    @NamedQuery(name = "Produccio.findByPosy1", query = "SELECT p FROM Produccio p WHERE p.posy1 = :posy1"),
    @NamedQuery(name = "Produccio.findByPosx2", query = "SELECT p FROM Produccio p WHERE p.posx2 = :posx2"),
    @NamedQuery(name = "Produccio.findByPosy2", query = "SELECT p FROM Produccio p WHERE p.posy2 = :posy2"),
    @NamedQuery(name = "Produccio.findByDataPlazSegur", query = "SELECT p FROM Produccio p WHERE p.dataPlazSegur = :dataPlazSegur")})
public class Produccio implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "data_planta")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataPlanta;
    @Basic(optional = false)
    @Column(name = "quantitat")
    private int quantitat;
    @Column(name = "origen")
    private String origen;
    @Column(name = "varietat")
    private String varietat;
    @Basic(optional = false)
    @Column(name = "terminado")
    private boolean terminado;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "posx1")
    private Integer posx1;
    @Column(name = "posy1")
    private Integer posy1;
    @Column(name = "posx2")
    private Integer posx2;
    @Column(name = "posy2")
    private Integer posy2;
    @Column(name = "data_plaz_segur")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataPlazSegur;
    @JoinColumn(name = "unitats_mesura_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private UnitatsMesura unitatsMesuraId;
    @JoinColumn(name = "camp_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Camp campId;
    @JoinColumn(name = "productes_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Producte productesId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "produccioId")
    private Collection<Tractament> tractamentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "produccioId")
    private Collection<Collita> collitaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "produccioId")
    private Collection<Abonat> abonatCollection;

    public Produccio() {
    }

    public Produccio(Integer id) {
        this.id = id;
    }

    public Produccio(Integer id, Date dataPlanta, int quantitat, boolean terminado) {
        this.id = id;
        this.dataPlanta = dataPlanta;
        this.quantitat = quantitat;
        this.terminado = terminado;
    }

    public Date getDataPlanta() {
        return dataPlanta;
    }

    public void setDataPlanta(Date dataPlanta) {
        this.dataPlanta = dataPlanta;
    }

    public int getQuantitat() {
        return quantitat;
    }

    public void setQuantitat(int quantitat) {
        this.quantitat = quantitat;
    }

    public String getOrigen() {
        return origen;
    }

    public void setOrigen(String origen) {
        this.origen = origen;
    }

    public String getVarietat() {
        return varietat;
    }

    public void setVarietat(String varietat) {
        this.varietat = varietat;
    }

    public boolean getTerminado() {
        return terminado;
    }

    public void setTerminado(boolean terminado) {
        this.terminado = terminado;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPosx1() {
        return posx1;
    }

    public void setPosx1(Integer posx1) {
        this.posx1 = posx1;
    }

    public Integer getPosy1() {
        return posy1;
    }

    public void setPosy1(Integer posy1) {
        this.posy1 = posy1;
    }

    public Integer getPosx2() {
        return posx2;
    }

    public void setPosx2(Integer posx2) {
        this.posx2 = posx2;
    }

    public Integer getPosy2() {
        return posy2;
    }

    public void setPosy2(Integer posy2) {
        this.posy2 = posy2;
    }

    public Date getDataPlazSegur() {
        return dataPlazSegur;
    }

    public void setDataPlazSegur(Date dataPlazSegur) {
        this.dataPlazSegur = dataPlazSegur;
    }

    public UnitatsMesura getUnitatsMesuraId() {
        return unitatsMesuraId;
    }

    public void setUnitatsMesuraId(UnitatsMesura unitatsMesuraId) {
        this.unitatsMesuraId = unitatsMesuraId;
    }

    public Camp getCampId() {
        return campId;
    }

    public void setCampId(Camp campId) {
        this.campId = campId;
    }

    public Producte getProductesId() {
        return productesId;
    }

    public void setProductesId(Producte productesId) {
        this.productesId = productesId;
    }

    @XmlTransient
    public Collection<Tractament> getTractamentCollection() {
        return tractamentCollection;
    }

    public void setTractamentCollection(Collection<Tractament> tractamentCollection) {
        this.tractamentCollection = tractamentCollection;
    }

    @XmlTransient
    public Collection<Collita> getCollitaCollection() {
        return collitaCollection;
    }

    public void setCollitaCollection(Collection<Collita> collitaCollection) {
        this.collitaCollection = collitaCollection;
    }

    @XmlTransient
    public Collection<Abonat> getAbonatCollection() {
        return abonatCollection;
    }

    public void setAbonatCollection(Collection<Abonat> abonatCollection) {
        this.abonatCollection = abonatCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Produccio)) {
            return false;
        }
        Produccio other = (Produccio) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Produccio[ id=" + id + " ]";
    }
    
}
